var status = -1;
var selectionLog = [];
var items = [1342102, 1352010, 1352110, 1352207, 1352217, 1352227, 1352237, 1352247, 1352257, 1352267, 1352277, 1352287, 1352297, 1352407, 1352507, 1352607, 1352708, 1352808, 1352809, 1352817, 1352827, 1352907, 1352917, 1352929, 1352936, 1352946, 1352958, 1352968, 1352976, 1353007, 1353106, 1353204, 1353304, 1353305, 1353404, 1353504, 1353604, 1353704, 1353804, 1354004];

function start() {
    action(1, 0, 0)
}

function action(e, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var d = "想要兑换哪一件武器？\r\n#b";
            for (var a = 0; a < items.length; a++) {
                d += "#L" + a + "##i" + items[a] + "##z" + items[a] + "##l\r\n"
            }
            im.askMenu(d)
        } else {
            if (status === a++) {
                im.dispose();
                var f = im.getItemId();
                im.gainItem(items[b], 1);
                im.gainItem(f, -1)
            }
        }
    }
};